/* IntegrityCheckFactory.java
 * 6 June 2012
 */
package za.ac.wits.elen7045.integrity.checks.factory;

import java.util.ArrayList;
import java.util.List;

import jass.modern.Pre;
import za.ac.wits.elen7045.exceptions.ProviderIdentifierInvalidException;
import za.ac.wits.elen7045.integrity.checker.interfaces.IntegrityCheckerFactoryInterface;
import za.ac.wits.elen7045.integrity.checker.interfaces.IntegrityCheckingInterface;
import za.ac.wits.elen7045.integrity.checks.AdditionCheck;
import za.ac.wits.elen7045.integrity.checks.DuplicateDataCheck;
import za.ac.wits.elen7045.integrity.checks.HellkomIntegrityChecker;
import za.ac.wits.elen7045.integrity.checks.VatCheck;
import za.ac.wits.elen7045.integrity.checks.interfaces.IntegrityCheck;

/**
 * Implementation of the IntegrityCheckFactory interface. Return a integrity checker on request of
 * our choosing. 
 * 
 * Since the checker is state less a new entity is created and returned each time.
 * @author Gerhard Visagie
 */
public class IntegrityCheckFactory implements IntegrityCheckerFactoryInterface {

	/* (non-Javadoc)
	 * @see za.ac.wits.elen7045.integrity.checker.interfaces.IntegrityCheckerFactoryInterface#getIntegrityChecker()
	 */
	@Override
	@Pre("providerIdentifier != null " +
		 "providerIdentifier.length > 0")
	public IntegrityCheckingInterface getIntegrityChecker(String providerIdentifier) throws ProviderIdentifierInvalidException{
		// For the purposes of the POC, we only have one provider, we could configure others
		//but for now we only have one
		
		if (providerIdentifier == "Hellkom"){					
			List<IntegrityCheck> checks = new ArrayList<IntegrityCheck>();
			checks.add(new AdditionCheck());
			checks.add(new DuplicateDataCheck());
			checks.add(new VatCheck());
			HellkomIntegrityChecker ic = new HellkomIntegrityChecker(checks);
			return ic;			
		}else{
			throw new ProviderIdentifierInvalidException();
		}
				 
	}

}
